import ajax from '@utils/ajax.js'

//班级信息
export async function classData(){
    const res= await ajax({
        url:'/class/showClass',
        type:'post'});
    return res;
}

//添加班级
export async function addData(url,type,data){
    const res= await ajax({
        url:url,
        type:type,
        data:data
    });
    return res;
}

//专业信息
export async function subjectData(){
    const res= await ajax({
        url:'/objects/showobject',
        type:'post'});
    return res;
}

//学生信息
export async function studentData({fanyeNum,yeshuNum,type,value}){
    const res= await ajax({
        url:'/students/showStudent',
        type:'post',
        data: {
            fanyeNum,
            yeshuNum,
            type,
            value
        }
    });
    return res;
}

//用过专业调用班级
export async function classRender(id){
    const res= await ajax({
        url:'/class/nextclass',
        type:'post',
        data: {
            objectId: id
        }
    });
    return res;
}

//删除学生
export async function deletStudentData(id){
    const res= await ajax({
        url:'/students/deletStudent',
        type:'post',
        data: {
            "_id": id
        }
    });
    return res;
}
//修改学生

export async function changeStudentData(id){
    const res= await ajax({
        url:'/students/changeStudent',
        type:'post',
        data: {
            "_id": id
        }
    });
    return res;
}
export async function changesStudent(id,name,age,sex,object,clas){
    const res= await ajax({
        url:'/students/changesStudent',
        type:'post',
        data: {
            _id: id,
            name: name,
            age: age,
            sex: sex,
            objectId: object,
            clasId: clas
        }
    });
    return res;
}
//注册
export async function userData(  username, password){
    const res= await ajax({
        url:'/users/zhuce',
        type:'post',
        data: {
            username, password
        }
    });
    return res;
}

//登录
export async function userLoginData(  username, password){
    const res= await ajax({
        url:'/users/login',
        type:'post',
        data: {
            username, password
        }
    });
    return res;
}